package com.sj.增删改查结点;

import com.sj.node.Node;

/**
 * @author sj
 * @date 2021/5/3
 **/
public class 删除链表结点 {
    public static LinkNode removeNode(LinkNode head,int val){
        if (head.val ==val) return head.next;
        LinkNode pre = head , cur = head.next;
        while (cur != null && cur.val != val){
            pre = cur;
            cur = cur.next;
        }
        if (cur != null) {
            pre.next = cur.next;
        }
        return head;
    }
}
